package com.wanmait.schedule.service.impl;

import com.wanmait.schedule.entity.Menu;
import com.wanmait.schedule.mapper.MenuMapper;
import com.wanmait.schedule.service.MenuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.ibatis.jdbc.Null;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 导航 服务实现类
 * </p>
 *
 * @author wanmait
 * @since 2022-03-02
 */
@Service
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements MenuService {

    @Resource
    private MenuMapper menuMapper;

    @Override
    public List<Menu> menus() {//找到所有的菜单

        List<Menu> menus = menuMapper.selectMenu();

        return menus;
    }

    @Override
    public void DeleteMenu(Integer id) {//逻辑删除

        menuMapper.deleteById(id);

    }

    @Override
    public void RecoverMenu(Integer id) {//恢复逻辑删除删除的数据

        menuMapper.recoverMenu(id);
    }

    @Override
    public void UpdateMenu(Integer id, String username) {//修改菜单的名称

        Menu menu = new Menu();
        menu.setId(id);
        menu.setTitle(username);
        menuMapper.updateById(menu);
    }

    @Override
    public List<Menu> UserMenus() {//用户看到的菜单
        List<Menu> UserMenu = menuMapper.selectList(null);
        return UserMenu;
    }
}
